<style scoped lang="less">
    .content {
        background-color: #f0f2f5;
        text-align: left;
    }

    .bottom {
        margin-top: 15px;
    }

    .pageContent {
        text-align: right;
        padding-top: 20px;
    }

    .num-info {
        .title {
            color: rgba(0, 0, 0, .45);
            font-size: 14px;
            height: 22px;
            line-height: 22px;
            overflow: hidden;
            text-overflow: ellipsis;
            word-break: break-all;
            white-space: nowrap;
        }

        .value {
            .total {
                color: rgba(0, 0, 0, .85);
                display: inline-block;
                line-height: 32px;
                height: 32px;
                font-size: 24px;
                margin-right: 32px;
            }

            .subtotal {
                color: rgba(0, 0, 0, .45);
                font-size: 16px;
                vertical-align: top;
                margin-right: 0;

                i {
                    font-size: 22px;
                    color: red;
                    transform: scale(.82);
                    margin-left: 4px;
                }
            }
        }
    }

    #chart, #myChart {
        width: 100%;
        height: 100px;
        margin: auto;
        top: -10px;
    }

    #search, #search1 {
        height: 100px;
    }

    #pie {
        height: 350px;
    }

    #sale, #scan {
        height: 350px;
    }

    .ivu-divider-horizontal {
        margin: 10px 0;
    }

    .txt-left {
        text-align: left;

        .title, a {
            color: rgba(0, 0, 0, .45);
            font-size: 14px;
        }

        .num {
            font-size: 30px;
            color: #000;
            margin-bottom: 10px;
        }

        .des, .footer {
            color: rgba(0, 0, 0, .65);
            font-size: 14px;

            i {
                font-size: 22px;
                margin-right: 10px;
            }
        }

        .des {
            margin-top: 23px;
        }

        .chart_divider {
            margin-top: -55px;
        }

        .progress {
            margin: 8px 0;
        }
    }

    .tab {
        margin-top: 15px;
        padding: 20px 10px 15px;
        background-color: #fff;

        .extra-item {
            display: inline-block;
            margin-right: 24px;

            a {
                margin-left: 24px;
            }
        }

        .title {
            font-size: 14px;
            color: rgba(0, 0, 0, 0.85);
            text-align: left;
        }
    }

</style>
<template>
    <!--分析页-->
    <div class="content">
        <Row class="txt-left" :gutter="12">
            <Col span="6">
                <Card>
                    <p class="title">订单数量</p>
                    <a href="javascript:;" slot="extra">
                        <Tooltip content="指标说明" placement="bottom">
                            <Icon type="ios-information-circle-outline"/>
                        </Tooltip>
                    </a>
                    <p class="num">{{orderCount}}</p>
                    <!-- <div class="des" >
                         同周比 12%
                         <Icon type="md-arrow-dropup" color="#f5222d"/>
                         日环比 11%
                         <Icon type="md-arrow-dropdown" color="#52c41a"/>
                     </div>-->
                    <div id="search"></div>
                    <Divider class="chart_divider"/>
                    <p>今日订单数量 {{orderCountToday}}</p>
                </Card>
            </Col>
            <Col span="6">
                <Card>
                    <p>总销售额</p>
                    <a href="javascript:;" slot="extra">
                        <Tooltip content="指标说明" placement="top">
                            <Icon type="ios-information-circle-outline"/>
                        </Tooltip>
                    </a>
                    <p class="num">￥ {{orderAmount}}</p>
                    <div id="chart"></div>
                    <Divider class="chart_divider"/>
                    <p>今日销售额 {{orderAmountToday}}</p>
                </Card>
            </Col>
            <Col span="6">
                <Card>
                    <p>学员数量</p>
                    <a href="javascript:;" slot="extra">
                        <Tooltip content="指标说明" placement="top">
                            <Icon type="ios-information-circle-outline"/>
                        </Tooltip>
                    </a>
                    <p class="num">{{userCount}}</p>
                    <div id="myChart"></div>
                    <Divider class="chart_divider"/>
                    <p>今日注册数量 {{userCountByToday}}</p>
                </Card>
            </Col>
            <Col span="6">
                <Card>
                    <p>课程数量</p>
                    <a href="javascript:;" slot="extra">
                        <Tooltip content="指标说明" placement="top">
                            <Icon type="ios-information-circle-outline"/>
                        </Tooltip>
                    </a>
                    <p class="num">{{courseCount}}</p>
                   <Progress :percent="0" status="success" hide-info class="progress"/>
                    <Divider/>
                    <div class="footer">
                        讲师数量 {{lectureCount}}
                       <!-- <Icon type="md-arrow-dropup" color="#f5222d"/>
                        日环比 11%
                        <Icon type="md-arrow-dropdown" color="#52c41a"/>-->
                    </div>
                </Card>
            </Col>
        </Row>
        <div class="tab">
            <Tabs>
                <div class="extra-wrap" slot="extra">
                  <!--  <div class="extra-item">
                        <a>今日</a>
                        <a>本周</a>
                        <a>本月</a>
                        <a>本年</a>
                    </div>-->
                    <!--<DatePicker type="daterange" placement="bottom-end" placeholder="开始日期 - 结束日期"></DatePicker>-->
                </div>
                <TabPane label="订单月统计">
                    <Row>
                        <Col span="15">

                            <div id="sale"></div>
                        </Col>
                        <Col span="9">
                            <p class="title">课程销售排行榜</p>
                            <rakinglist :list="rankList"></rakinglist>
                        </Col>
                    </Row>
                </TabPane>
              <!--  <TabPane label="VIP统计">
                    <Row>
                        <Col span="15">
                            <p class="title">VIP开通趋势</p>
                            <div id="scan"></div>
                        </Col>
                        <Col span="9">
                            <p class="title">门店销售排行榜</p>
                            <rakinglist :list="rankList"></rakinglist>
                        </Col>
                    </Row>
                </TabPane>-->
            </Tabs>
        </div>
        <Row :gutter="15" class-name="bottom" v-if="1==2">
            <Col span="12">
                <Card>
                    <p slot="title">热门搜索</p>
                    <!-- <Row :gutter="25">
                         <Col span="12">
                             <div class="num-info">
                                 <span class="title">搜索用户数</span>
                                 <div class="value">
                                     <span class="total">12321</span>
                                     <span class="subtotal">71.2 <Icon type="md-arrow-dropup" color="#f5222d"/></span>
                                 </div>
                             </div>
                             <div id="search2"></div>
                         </Col>
                         <Col span="12">
                             <div class="num-info">
                                 <span class="title">搜索用户数</span>
                                 <div class="value">
                                     <span class="total">12321</span>
                                     <span class="subtotal">71.2 <Icon type="md-arrow-dropdown" color="#f5222d"/></span>
                                 </div>
                             </div>
                             <div id="search1"></div>
                         </Col>
                     </Row>-->
                    <Table border :columns="columns5" :data="data5"></Table>
                    <div class="pageContent">
                        <Page :total="100"/>
                    </div>
                </Card>
            </Col>
            <Col span="12">
                <Card>
                    <p slot="title">销售额占比</p>
                    <a href="javascript:;" slot="extra">
                        <Icon type="ios-more"/>
                    </a>
                    <div>
                        <ButtonGroup size="large">
                            <Button>全渠道</Button>
                            <Button>线上</Button>
                            <Button>门店</Button>
                        </ButtonGroup>
                    </div>
                    <div id="pie"></div>
                </Card>
            </Col>
        </Row>
    </div>
</template>
<script>
    import rakinglist from './rakinglist'
    import {
        homereport
    } from "@/api/index";
    //import echarts from 'echarts'
    let echarts = require('echarts/lib/echarts')
    require('echarts/lib/chart/line')
    require('echarts/lib/chart/bar')
    require('echarts/lib/chart/pie')
    require('echarts/lib/component/tooltip')
    require('echarts/lib/component/legend')
    const rankList = []

    export default {
        name: '',
        props: {},
        data() {
            return {
                userCountByToday: 0,
                userCount: 0,
                orderCountToday: 0,
                orderAmountToday: 0,
                orderCount: 0,
                orderAmount: 0,
                courseCount:0,
                lectureCount:0,
                sale_amounts: [],
                sale_dates: [],
                year_amounts:[],
                sale_nums: [],
                user_nums: [],
                rankList: [{
                    name: "",
                    total: ""
                }],
                columns5: [
                    {
                        title: '排名',
                        key: 'sorts'
                    },
                    {
                        title: '搜索关键词',
                        key: 'word'
                    },
                    {
                        title: '用户数',
                        key: 'num',
                        sortable: true
                    },
                    {
                        title: '周涨幅',
                        key: 'zhang'
                    }
                ],
                data5: [
                    {
                        sorts: 1,
                        word: '关键词-0',
                        num: 777,
                        zhang: '21%'
                    },
                    {
                        sorts: 2,
                        word: '关键词-1',
                        num: 777,
                        zhang: '21%'
                    },
                    {
                        sorts: 3,
                        word: '关键词-2',
                        num: 777,
                        zhang: '21%'
                    },
                    {
                        sorts: 4,
                        word: '关键词-3',
                        num: 777,
                        zhang: '21%'
                    },
                    {
                        sorts: 5,
                        word: '关键词-4',
                        num: 777,
                        zhang: '21%'
                    }
                ]
            };
        },
        methods: {
            getData() {
                homereport().then(res => {

                    if (res.status === true) {
                        this.userCountByToday = res.data.userCountByToday;
                        this.userCount = res.data.userCount;
                        this.orderCountToday = res.data.orderCountToday;
                        this.orderAmountToday = res.data.orderAmountToday;
                        this.orderCount = res.data.orderCount;
                        this.orderAmount = res.data.orderAmount;
                        this.sale_dates = res.data.sale_dates;
                        this.sale_nums = res.data.sale_nums;
                        this.user_nums = res.data.user_nums;
                        this.sale_amounts = res.data.sale_amounts;
                        this.year_amounts = res.data.year_amounts;
                        this.courseCount = res.data.courseCount;
                        this.lectureCount = res.data.lectureCount;
                        this.rankList = res.data.courseList;
                        this.draw();
                    }
                });
            },
            draw() {
                //销售额统计
                let myChart = echarts.init(document.getElementById('chart'))
                myChart.setOption(this.amount_opt());
                //搜索线形图
                let lineChart = echarts.init(document.getElementById('search'))
                lineChart.setOption(this.opt());
                /*  //搜索线形图
                  let lineChart1 = echarts.init(document.getElementById('search1'))
                  lineChart1.setOption(this.opt());*/
                //顶部 柱状图
                let chart = echarts.init(document.getElementById('myChart'))
                chart.setOption({
                    color: ['#3aa0ff'],
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            type: 'shadow'
                        }
                    },
                    grid: {
                        left: '2%',
                        right: '4%',
                        top: '0',
                        containLabel: false
                    },
                    xAxis: [
                        {
                            show: false,
                            type: 'category',
                            data: this.sale_dates

                        }
                    ],
                    yAxis: [
                        {
                            show: false,
                            type: 'value'
                        }
                    ],
                    series: [
                        {
                            type: 'bar',
                            barWidth: '60%',
                            data: this.user_nums
                        }
                    ]
                });
                //tab柱状图(销售)
                let bar = echarts.init(document.getElementById('sale'))
                bar.setOption(this.option())
              /*  //tab柱状图(访问量)
                let bar_scan = echarts.init(document.getElementById('scan'))
                bar_scan.setOption(this.option())*/
               /* //      饼状图
                let pie = echarts.init(document.getElementById('pie'))
                pie.setOption({
                    tooltip: {
                        trigger: 'item',
                        formatter: "{a} <br/>{b}: {c} ({d}%)"
                    },
                    legend: {
                        orient: 'vertical',
                        x: 'right',
                        y: 'bottom',
                        data: ['直达', '邮件营销', '联盟广告', '视频广告', '百度']
                    },
                    series: [
                        {
                            name: '访问来源',
                            type: 'pie',
                            radius: ['40%', '55%'],
                            label: {
                                normal: {
                                    formatter: '  {b}：{d}%  ',

                                    borderWidth: 1,
                                    borderRadius: 4,
                                    label: {

                                        fontSize: 16,
                                        lineHeight: 33


                                    }
                                }
                            },
                            data: [
                                {value: 335, name: '直达'},
                                {value: 310, name: '邮件营销'},
                                {value: 234, name: '联盟广告'},
                                {value: 135, name: '视频广告'},
                                {value: 1048, name: '百度'},
                            ],
                            itemStyle: {
                                normal: {
                                    color: function (params) {
                                        var colorList = [
                                            '#3aa1ff', '#36cbcb', '#4ecb73', '#Fbd437', '#F2637b'
                                        ];
                                        return colorList[params.dataIndex]
                                    }
                                }
                            }
                        }
                    ]
                });*/
            },

            option() {
                let opt = {
                    color: ['#3aa0ff'],
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {  // 坐标轴指示器，坐标轴触发有效
                            type: 'shadow'// 默认为直线，可选为：'line' | 'shadow'
                        }
                    },
                    grid: {
                        left: '3%',
                        right: '4%',
                        top: '10%',
                        containLabel: false
                    },
                    xAxis: [
                        {
                            type: 'category',
                            data: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
                            axisTick: {
                                alignWithLabel: true
                            },
                            axisLine: {
                                lineStyle: {
                                    color: '#ccc',

                                }
                            }

                        }
                    ],
                    yAxis: [
                        {

                            type: 'value',
                            splitLine: {
                                show: true,
                                lineStyle: {
                                    type: 'dashed'
                                }
                            },
                            axisLine: {
                                show: false
                            }
                        }
                    ],
                    series: [
                        {

                            type: 'bar',
                            barWidth: '60%',
                            data: this.year_amounts
                        }
                    ]
                };
                return opt;
            },
            //订单数量统计
            opt() {
                let param = {
                    color: '#b8ddff',
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            type: 'line'

                        }
                    },
                    grid: {
                        left: '2%',
                        right: '4%',
                        top: '0',
                        containLabel: false
                    },
                    xAxis: [
                        {
                            show: false,
                            type: 'category',
                            boundaryGap: false,
                            data: this.sale_dates
                        }
                    ],
                    yAxis: [
                        {
                            type: 'value',
                            show: false,
                        }
                    ],
                    series: [
                        {
                            type: 'line',
                            label: {
                                normal: {
                                    show: false,
                                }
                            },
                            areaStyle: {
                                normal: {
                                    color: '#b8ddff'
                                }
                            },
                            smooth: 'max',
                            smoothMonotone: 'max',
                            sampling: 'max',
                            data: this.sale_nums
                        }
                    ]
                }
                return param;
            },
            //订单数量统计
            amount_opt() {
                let param = {
                    color: '#b8ddff',
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            type: 'line'

                        }
                    },
                    grid: {
                        left: '2%',
                        right: '4%',
                        top: '0',
                        containLabel: false
                    },
                    xAxis: [
                        {
                            show: false,
                            type: 'category',
                            boundaryGap: false,
                            data: this.sale_dates
                        }
                    ],
                    yAxis: [
                        {
                            type: 'value',
                            show: false,
                        }
                    ],
                    series: [
                        {
                            type: 'line',
                            label: {
                                normal: {
                                    show: false,
                                }
                            },
                            areaStyle: {
                                normal: {
                                    color: '#b8ddff'
                                }
                            },
                            smooth: 'max',
                            smoothMonotone: 'max',
                            sampling: 'max',
                            data: this.sale_amounts
                        }
                    ]
                }
                return param;
            }
        },
        mounted() {
            this.getData();
        },
        created() {

        },
        components: {
            rakinglist
        }
    }
</script>
